export const state = () => ({
  currentUser:{},
  roles:[]
})
export const mutations = {
  setCurrentUser(state,value){
    state.currentUser = value
  },
  clearCurrentUser(state){
    state.currentUser = {}
  },
  /**
   * 设置角色信息数据
   * @param state
   * @param value
   */
  setRoles(state,value){
    if(value){
      state.roles = value
    }
  }
}

export const actions = {
  //更新登录用户信息
  updateUser({state},user){
    if(user != null){
      state.commit("user/setCurrentUser",user)
    }else{
      //用户信息不能为空
    }
  },
  /**
   * 清空登录用户信息
   * @param state
   */
  clearUser({state}){
    state.commit("user/setCurrentUser",{})
  }
}

export default {
  namespace:true,
  state,
  mutations,
  actions
}
